#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N=1e5+10;
int n,m,k,a[N],na[N],c[N],ans;
signed main(){
    cin.tie(0),cout.tie(0);
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>na[i];
    }
    for(int i=1;i<=m;i++){
        cin>>c[i];
    }
    int tmp=1;
    while(tmp<n){
        k++;
        tmp*=2;
    }
    for(int i=1;i<=k;i++){
        for(int j=1;j<=1<<(k-i);j++){
            int x;
            cin>>x;
            mp[{i,j}]=x;
        }
    }
    int T;
    cin>>T;
    while(T--){
        int x[4];
        cin>>x[0]>>x[1]>>x[2]>>x[3];
        srand(time(0));
        cout<<rand();
    }
    return 0;
}

